from fastapi import APIRouter
from app.core.responses import Response
from app.services.sservices import SServices

router = APIRouter(prefix="/services")


@router.get("/{id}", summary="获取服务详细")
async def index(id: int):
    # 获取服务详细
    data = SServices.get_with_one(id)
    if not data:
        return Response.failed(message="服务不存在")
    return Response.success(data.serialize())


@router.get("/scopes/{service_id}", summary="获取服务子分类")
async def index(service_id: int):
    service = SServices.get_one(service_id)
    scopes = service.scopes
    data = {
        "start_price":service.start_price,
        "scopes": scopes.serialize()
    }
    return Response.success(data)
